<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>{{~#block title}}{{/block~}}</title>

    <!-- favicon icon -->
    <link href="{{ static_path }}/favicon.ico" rel="shortcut icon">

    <!-- base css -->
    <link href="{{ static_path }}/css/base.css" rel="stylesheet">
    <link href="{{ static_path }}/highlight/css/default.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    {{~#block head}}{{/block~}}
  </head>
  <body>
    <nav class="navbar navbar-default">
      <div class="container">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="/"><b>Rust</b> China</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="navbar-collapse">
          <ul class="nav navbar-nav navbar-right">
            {{#if login_user}}
              <li role="presentation" class="dropdown">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
                  {{login_user.username}} <span class="caret"></span>
                </a>
                <ul class="dropdown-menu">
                  <li><a href="/user/{{login_user.id}}">个人中心</a></li>
                  <li><a href="javascript:void(0)" id="logoutBtn">退出</a></li>
                </ul>
              </li>
            {{else}}
              <li><a href="/user/register">注册</a></li>
              <li><a href="/user/login">登录</a></li>
            {{/if}}
          </ul>
        </div><!-- /.navbar-collapse -->
      </div><!-- /.container-fluid -->
    </nav>

    {{~#block page}}{{/block~}}
    <footer>
        <div class="container text-muted">
            <p>中国 Rust 社区，致力于构建活跃的 Rust 中文社区。</p>
            written in <a href="https://www.rust-lang.org/">Rust</a>
            •
            <a href="/rss">RSS</a>
            •
            <a href="https://github.com/liyuan462/rust_lang_cn">源码地址</a>
            •
            <a href="https://rust-cn.pubu.im/reg/prmkl2w7n2n9fky">交流</a>
        </div>
    </footer>
    <script src="{{ static_path }}/js/jquery.min.js"></script>
    <script src="{{ static_path }}/js/jquery.form.js"></script>
    <script src="{{ static_path }}/js/moment.min.js"></script>
    <script src="{{ static_path }}/bootstrap/js/bootstrap.min.js"></script>
    <script>
     var _hmt = _hmt || [];
     (function() {
         var hm = document.createElement("script");
         hm.src = "//hm.baidu.com/hm.js?77e9d9fba169430bae702f74a50f5f9b";
         var s = document.getElementsByTagName("script")[0];
         s.parentNode.insertBefore(hm, s);
     })();
    </script>

    <script>
     $("#logoutBtn").click(function() {
         $.ajax({
             url: "/user/logout",
             method: "POST",
             success: function() {
                 location.href = "/";
             }
         });
     });

     (function(){
      var timesNode = $('.time-label')
      for (var i = timesNode.length - 1; i >= 0; i--) {
        timesNode[i].innerHTML = moment(timesNode[i].getAttribute('date-time')).fromNow()
      }

      // fancybox
      $(".media-body img,.panel-body img").wrap(function(){
        return "<a class='fancybox' style='display:block' href="+this.getAttribute('src')+"></a>"
      })

      // $(".fancybox").fancybox()

     })()
    </script>
    {{~#block footer_js}}{{/block~}}
  </body>
</html>
